/*
 * Copyright © 2019-2020  Whale Cloud, Inc. All Rights Reserved.
 *
 * Notice: Whale Cloud Inc copyrights this specification.
 * No part of this specification may be reproduced in any form or means,
 * without the prior written consent of Whale Cloud Inc.
 *
 */
package com.wteam.modules.system.domain;

import javax.validation.constraints.*;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import com.wteam.base.BaseCons;
import com.wteam.base.BaseEntity;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.elasticsearch.annotations.Document;


import java.sql.Date;

/**
 * 课程 持久类.
 *
 * @author herry_wong
 * @since 2020-12-28
 */
@Entity
@Getter
@Setter
@Where(clause = BaseCons.SOFT_DELETE)
@Table(name="course")
public class Course extends BaseEntity{

    public final static String ENTITY_NAME = "课程";

    @Id
    @org.springframework.data.annotation.Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NotNull(groups = Update.class)
    @Column(name = "id")
    private Long id;

    /** 课程名称 */
    @ApiModelProperty( "课程名称")
    @Column(name = "name")
    private String name;

    /** 课程简介 */
    @ApiModelProperty( "课程简介")
    @Column(name = "detail")
    private String detail;

    /** 班级id */
    @ApiModelProperty( "班级id")
    @Column(name = "class_id")
    private Long classId;

    /** 学分类型 */
    @ApiModelProperty( "学分类型")
    @Column(name = "type_id")
    private Long typeId;

    /** 学分 */
    @ApiModelProperty( "学分")
    @Column(name = "credit")
    private Double credit;

    /** 是否必修 */
    @ApiModelProperty( "是否必修")
    @Column(name = "compulsory")
    private Boolean compulsory;

    @Column(name = "start_time")
    private Date startTime;

    @Column(name = "end_time")
    private Date endTime;

    /** 名额 */
    private Integer places;

    //平时分占比
    @Column(scale = 1)
    private Double radio;

    private String code;

    @Column(name = "teacherId")
    private Long teacherId;

    public void copy(Course source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}